<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增申请开票')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sqkp-add">
        	<h4 class="form-header h4">开票详情</h4>
        	<input type="hidden" name="gcProjectid" id="gcProjectid" th:value="${sjContract.gcProjectId}">
            <input type="hidden" id="approvename" name="approvename" th:value="${approvename}" />
        	<div class="form-group">    
                <label class="col-sm-2 control-label is-required">项目编号：</label>
                <div class="col-sm-4">
                    <input name="orderNo" class="form-control" type="text" autoComplete="off" th:value="${sjContract.orderNo}" readonly="readonly" required>
                </div>
                <label class="col-sm-2 control-label is-required">申请时间：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="sqsj" class="form-control" placeholder="yyyy-MM-dd" type="text" autoComplete="off" required th:value="${#dates.format(sqsj, 'yyyy-MM-dd')}">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">项目名称：</label>
                <div class="col-sm-4">
                    <input name="xmmc" class="form-control" type="text" autoComplete="off" th:value="${sjContract.projectName}" readonly="readonly" required>
                </div>
                <label class="col-sm-2 control-label is-required">项目地址：</label>
                <div class="col-sm-4">
                    <input name="xmdz" class="form-control" type="text" autoComplete="off"  required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">合同金额：</label>
                <div class="col-sm-4">
                    <input name="htje" class="form-control" type="text" autoComplete="off" th:value="${sjContract.htje}" readonly="readonly" required>
                </div>
                <label class="col-sm-2 control-label is-required">项目类型：</label>
                <div class="col-sm-4">
		            <select name="xmlx" class="form-control" th:with="type=${@dict.getType('sj_nsct_type')}" required>
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
            </div>
<!--             <div class="form-group">     -->
<!--                 <label class="col-sm-2 control-label is-required">本次申请开票金额：</label> -->
<!--                 <div class="col-sm-4"> -->
<!--                     <input name="bcsqkpje" id="bcsqkpje" class="form-control" type="text" autoComplete="off" onchange="getHjje()" required> -->
<!--                 </div> -->
<!--                 <label class="col-sm-2 control-label is-required">预计收款金额：</label> -->
<!--                 <div class="col-sm-4"> -->
<!--                     <input name="yjskje" class="form-control" type="text" autoComplete="off" required> -->
<!--                 </div> -->
<!--             </div> -->
            <div class="form-group"> 
            	<label class="col-sm-2 control-label is-required">单位名称/税号：</label>
                <div class="col-sm-4">
                    <input name="shuih" class="form-control" type="text" autoComplete="off" th:value="${shuih}" readonly="readonly" required>
                </div>   
                <label class="col-sm-2 control-label is-required">发票类型：</label>
                <div class="col-sm-4">
                    <select name="fplx" class="form-control" th:with="type=${@dict.getType('gcgl_project_fp')}" required>
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
                
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">单位开户行/帐号：</label>
                <div class="col-sm-4">
                    <input name="kaihuh" class="form-control" type="text" autoComplete="off" th:value="${kaihuh}" readonly="readonly" required>
                </div>
                <label class="col-sm-2 control-label is-required">单位地址/电话：</label>
                <div class="col-sm-4">
                    <input name="dizhi" class="form-control" type="text" autoComplete="off" th:value="${dizhi}" readonly="readonly" required>
                </div>
            </div>
            <div class="form-group">    
<!--                 <label class="col-sm-2 control-label">已开发票时间：</label> -->
<!--                 <div class="col-sm-4"> -->
<!--                     <div class="input-group date"> -->
<!--                         <input name="ykfpsj" class="form-control"  th:value="${ykfpsj}" placeholder="yyyy-MM-dd" type="text" autoComplete="off"> -->
<!--                         <span class="input-group-addon"><i class="fa fa-calendar"></i></span> -->
<!--                     </div> -->
<!--                 </div> -->
				<label class="col-sm-2 control-label is-required">本次申请开票金额：</label>
                <div class="col-sm-4">
                    <input name="itemje" id="itemje" class="form-control" type="text" autoComplete="off" onchange="getHjje()" required>
                </div>
                <label class="col-sm-2 control-label">已开发票金额：</label>
                <div class="col-sm-4">
                    <input name="ykfpje" id="ykfpje" class="form-control" type="text" autoComplete="off" th:value="${ykfpje}" readonly="readonly">
                </div>
                
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">发票备注：</label>
                <div class="col-sm-4">
                    <input name="itemmc" class="form-control" type="text" autoComplete="off" required>
                </div>
                <label class="col-sm-2 control-label is-required">收款公司：</label>
            	<div class="col-sm-4">
            		<select name="ztdw" class="form-control" th:with="type=${@dict.getType('sj_gongs')}">
                    	<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                	</select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">税率：</label>
                <div class="col-sm-4">
                    <select name="itemsl" class="form-control" >
		                <option th:value="9">9%</option>
		                <option th:value="6">6%</option>
		                <option th:value="3">3%</option>
		                <option th:value="1">1%</option>
		                <option th:value="0">0%</option>
		                <option th:value="11">11%</option>
		                <option th:value="13">13%</option>
		            </select>
                </div>
                <label class="col-sm-2 control-label is-required">建筑服务发生地（与合同一致）：</label>
                <div class="col-sm-4">
                    <select name="itemgg" class="form-control" required>
		                <option th:value="与合同一致">与合同一致</option>
		                <option th:value="与合同不一致">与合同不一致</option>
		            </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label is-required">合计(累计开票金额)：</label>
                <div class="col-sm-4">
                    <input name="hej" id="hej" class="form-control" type="text" autoComplete="off" required readonly="readonly">
                </div>
                <label class="col-sm-2 control-label is-required">管理费标准%：</label>
                <div class="col-sm-4">
                    <input name="glf" class="form-control" type="text" autoComplete="off" required >
                </div>
            </div>
            <div class="form-group">  
            	<label class="col-sm-2 control-label is-required">税金%：</label>
                <div class="col-sm-4">
                    <input name="suij" class="form-control" required type="text" autoComplete="off" >
                </div> 
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注：</label>
                <div class="col-sm-10">
                    <textarea name="memo" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-2 control-label is-required">商务运营：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="swyy" name="swyy" class="form-control" type="hidden">
                    	<input id="swyyId" name="swyyId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel1()" id="swyyStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-2 control-label is-required">财务审核：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="cw" name="cw" class="form-control" type="hidden">
                    	<input id="cwId" name="cwId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel2()" id="cwStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-2 control-label is-required">副总审批：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="fzjl1" name="fzjl1" class="form-control" type="hidden">
                    	<input id="fzjl1Id" name="fzjl1Id" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel3()" id="fzjl1Str" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-2 control-label is-required">副总审批：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="fzjl2" name="fzjl2" class="form-control" type="hidden">
                    	<input id="fzjl2Id" name="fzjl2Id" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel4()" id="fzjl2Str" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
            <div class="form-group">
            	<label class="col-sm-2 control-label is-required">总经理：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="zjl" name="zjl" class="form-control" type="hidden">
                    	<input id="zjlId" name="zjlId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel5()" id="zjlStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
                <label class="col-sm-2 control-label is-required">出纳：</label>
                <div class="col-sm-4">
                	<div class="input-group">
                    	<input id="cn" name="cn" class="form-control" type="hidden">
                    	<input id="cnId" name="cnId" class="form-control" type="hidden">
                    	<input class="form-control" type="text" onclick="selectlevel6()" id="cnStr" readonly="true" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
                </div>
            </div>
        </form>
        	<h4 class="form-header h4" style="margin-top: 25px;">历史开票信息</h4>
            <div class="form-group">
                <div class="col-sm-12" th:each="lis,status:${sqkplis}">
                	<span>开票金额：</span>
                	<span th:text="${lis.itemje}">&nbsp;</span>
                	<span>&nbsp;&nbsp;申请时间：</span>
                	<span th:text="${lis.createUser}">&nbsp;</span>
                </div>
            </div>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/sqkp";
        var hej = 0;
        $("#form-sqkp-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.saveTab(prefix + "/add", $('#form-sqkp-add').serialize());
            }
        }
        
        function getHjje(){
        	console.log($("#itemje").val());
        	console.log($("#ykfpje").val());
        	//hej = math.add($("#itemje").val(),$("#ykfpje").val());
        	hej = parseFloat($("#itemje").val())+parseFloat($("#ykfpje").val());
        	$("#hej").val(hej);
        }

        $("input[name='sqsj']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='xmfzrAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='ykfpsj']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='cwkprAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='zjlspAt']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
      //选择用户level1
		function selectlevel1() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel1User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel1User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#swyyId").val(rows[0].userId);
            $("#swyy").val(rows[0].userName);
            $("#swyyStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level2
		function selectlevel2() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel2User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel2User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#cwId").val(rows[0].userId);
            $("#cw").val(rows[0].userName);
            $("#cwStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level3
		function selectlevel3() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel3User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel3User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#fzjl1Id").val(rows[0].userId);
            $("#fzjl1").val(rows[0].userName);
            $("#fzjl1Str").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level4
		function selectlevel4() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel4User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel4User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#fzjl2Id").val(rows[0].userId);
            $("#fzjl2").val(rows[0].userName);
            $("#fzjl2Str").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level5
		function selectlevel5() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel5User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel5User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#zjlId").val(rows[0].userId);
            $("#zjl").val(rows[0].userName);
            $("#zjlStr").val(rows[0].userName);
            $.modal.closeAll();
        }
		
		//选择用户level6
		function selectlevel6() {
			var options = {
		       title: '选择用户',
		       url: "/sj/config/invokeUser",
		       width: '1000',
		       height: '670',
		       callBack: doSubmitlevel6User
		    };
		    $.modal.openOptions(options);
		}
	 	
		function doSubmitlevel6User(index, layero){
            var rows = layero.find("iframe")[0].contentWindow.getSelections();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录！");
                return;
            }
            
            if (rows.length > 1) {
                $.modal.alertWarning("请勿选择多条记录！");
                return;
            }
            
            $("#cnId").val(rows[0].userId);
            $("#cn").val(rows[0].userName);
            $("#cnStr").val(rows[0].userName);
            $.modal.closeAll();
        }

    </script>
</body>
</html>